#
# Makefile for the PF_RING FT examples
#

#
# PF_RING
#
PFRINGDIR  = ../lib
LIBPFRING  = ${PFRINGDIR}/libpfring.a

#
# PF_RING aware libpcap
#
O_FLAG     = -DHAVE_PF_RING @HAVE_NDPI@
EXTRA_LIBS = @NDPI_LIB@
PCAPDIR    = ../libpcap
LIBPCAP    = ${PCAPDIR}/libpcap.a  ${EXTRA_LIBS}

#
# Search directories
#
PFRING_KERNEL=../../kernel
INCLUDE    = -I${PFRING_KERNEL} -I${PFRINGDIR} -I${PCAPDIR} -Ithird-party `../lib/pfring_config --include` @NDPI_INC@

#
# C compiler and flags
#
#
# CROSS_COMPILE=arm-mv5sft-linux-gnueabi-
#
CC         = ${CROSS_COMPILE}gcc #--platform=native
CFLAGS     = @CFLAGS@ ${O_FLAG} -Wall -Wno-unused-function -Wno-format-truncation ${INCLUDE} @HAVE_PF_RING_FT@

#
# User and System libraries
#
LIBS       = ${LIBPCAP} ${LIBPFRING} ${LIBPCAP} ${LIBPFRING} `../lib/pfring_config --libs` `../libpcap/pcap-config --additional-libs --static` -lpthread @SYSLIBS@ -lrt -lm

#
# Object files
#
%.o: %.c ftutils.c
	${CC} ${CFLAGS} -c $< -o $@

#
# Main targets
#
FTPROGS = 
ifneq (@HAVE_PF_RING_FT@,)
FTPROGS = ftflow ftflow_pcap fttest
ifneq (@HAVE_HYPERSCAN@,)
LIBS   += /usr/local/lib/libhs.a
CFLAGS += -I/usr/local/include/hs/
endif
endif

TARGETS = ${FTPROGS}

all: ${TARGETS}

ftflow: ftflow.o ${LIBPFRING}
	${CC} ${CFLAGS} ftflow.o ${LIBS} -o $@

ftflow_pcap: ftflow_pcap.o ${LIBPFRING}
	${CC} ${CFLAGS} ftflow_pcap.o ${LIBS} -o $@

fttest: fttest.o ${LIBPFRING}
	${CC} ${CFLAGS} fttest.o ${LIBS} -o $@

install: ${TARGETS}
ifneq (@HAVE_PF_RING_FT@,)
	mkdir -p $(DESTDIR)/usr/bin
	cp $(TARGETS) $(DESTDIR)/usr/bin/
endif

clean:
	@rm -f ${TARGETS} *.o *~
